/**
 * Created by zhtt on 2017/5/6.
 */
/**  Hello **/
/*angular.module('supermarketApp').component('home', {
    template:  '<h3>{{$ctrl.greeting}} galaxy!</h3>' +
    '<button >toggle greeting</button>',
    controller: function() {
        alert("OK")
    }
})*/
supermarketApp.controller("HomeCtrl", ["$scope", "$timeout","OrderService",function ($scope, $timeout,OrderService) {
    init();
    function init() {
        data();
        loadOrder();
        statisticsBySupermark();
        statisticsByYear();
    }
    function data() {
        $scope.data={
            orderList:null/*订单*/
        }
    }
    /** 加载订单 **/
    function loadOrder() {
        var url="js/data/orderList.json";
        OrderService.getOrderList(url,function (data) {
            $scope.data.order=data;
        })
    }
    /*超市排行*/
    function statisticsBySupermark() {
        // 基于准备好的dom，初始化echarts实例
        var myChart = echarts.init(document.getElementById('statisticsBySupermarkChart'));
        // 使用刚指定的配置项和数据显示图表。
        myChart.setOption(statisticsBySupermarkOption);
    }
    function statisticsByYear() {
        var myChart = echarts.init(document.getElementById('statisticsByYearChar'));
        myChart.setOption(statisticsByYearOption,true);
    }
}]);